#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include <string>
#include <iostream>

using namespace std;
using namespace testing;

template <typename T = int>
class Templa {
public:
    void set(T t) 
    {
        this->m_t = t;
    }

    T get() 
    {
        return m_t;
    }
private:
    T m_t;
};

template <typename T = int>
class MockTempla : public Templa<T> {
public:
    MOCK_METHOD(T, get, ());
};

TEST(sample, cpp_class_template_int)
{
    MockTempla<int> templa;
    EXPECT_CALL(templa, get())
        .WillRepeatedly(Return(1));
    ASSERT_EQ(1, templa.get());
}

TEST(sample, cpp_class_template_string)
{
    MockTempla<string> templa;
    EXPECT_CALL(templa, get())
        .WillRepeatedly(Return("Hello, templa!"));
    ASSERT_EQ("Hello, templa!", templa.get());
}

int main(int argc, char *argv[])
{
    Templa<string> templa;
    templa.set("Hello, templa!");
    cout << templa.get() << endl;

    ::testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}
